home *** CD-ROM | disk | FTP | other *** search
- Date: Sat, 12 Jun 1993 09:04:52 -0800
- From: RPaige@ucsd.edu (Robert Paige)
- Subject: Re: Undo/Auto Backup
-
- >2) You can set up a process that, at appointed hours, beams the data from
- >all fields in all datafiles into disk files stored elsewhere. If you are
- >running v3 or server, this could take place unbeknownst to users. The Send
- >Record command would work for this as long as the database structure would
- >not change between backup and restore. Otherwise you would need to write
- >your own export procedure (more work).
-
- The following should work to backup and restore your database, with the
- above restrictions. If you call these as a new process, they open their own
- progress windows:
-
- `Procedure: zBACKUP($1:pathname)
-
- `$1 = pathname to store files in
-
- `backs-up all the data files to external files in a selected folder
-
- If (count parameters>=1)
- $FolderPath:=$1
- else
- `if $1 is not passed, files will be saved in same folder as
- `structure (or 4D Client)
- $FolderPath:=""
- end if
-
- MESSAGES OFF `4D progress messages
- MESSAGE("") `open a default message window
- For ($FileNum;1;Count files)
- SET WINDOW TITLE(Filename($FileNum)+": "+String($FileNum)+" of
- "+String(Count files))
- $msg:="Backing-up "+String(Records in file(File($FileNum)>))+"
- Records"+Char(13)
- MESSAGE($msg)
- SET CHANNEL(12;$FolderPath+Filename($FileNum))
- $FilePtr:=File($FileNum)
- ALL RECORDS($FilePtr>)
- APPLY TO SELECTION($FilePtr>;SEND RECORD($FilePtr>))
- SET CHANNEL(11)
- End for
-
-
- `Procedure: zRESTORE($1:pathname)
-
- `$1 = pathname to get files from
-
- `restores the records in the data files from separate documents
-
- If (count parameters>=1)
- $FolderPath:=$1
- else
- `if $1 is not passed, files will be retrieved from same folder as
- `structure (or 4D Client)
- $FolderPath:=""
- end if
-
- MESSAGES OFF `4D progress messages
- MESSAGE("") `open default message window
- For ($FileNum;1;Count files)
- $FullPath:=$FolderPath+Filename($FileNum)
- SET WINDOW TITLE(Filename($FileNum)+": "+String($FileNum)+" of
- "+String(Count files))
- MESSAGE("Restoring File")
- $FilePtr:=File($FileNum)
- SET CHANNEL(10;$FullPath)
- RECEIVE RECORD($FilePtr>)
- $RecCount:=0
- While (ok=1)
- $RecCount:=$RecCount+1
- SAVE RECORD($FilePtr>)
- RECEIVE RECORD($FilePtr>)
- If ($RecCount/10=Int($RecCount/10)) `display progress every 10 records
- MESSAGE(String($RecCount)+" records restored.")
- End if
- End while
- SET CHANNEL(11)
- End if
- ----------------------------------------
- Robert Paige
- Internet: rpaige@ucsd.edu
- HIV Neurobehavioral Research Center
- Department of Psychiatry
- UCSD School of Medicine, San Diego, CA
- ----------------------------------------
- >> Usual disclaimers apply. <<
- ----------------------------------------
-
-
-